package tjs.study.notes.dotest.jdk.map;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by Nicky.Tang on 2021/11/19 3:57 下午
 *
 * @since 02.12.10
 */
public class DoOfHashMap {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        for (int i = 0; i < 100; i++) {
            System.out.println(i & 3);
            map.put("a" + i, "v" + i);
        }
        map.get("a");

        new Integer(1).hashCode();

        ConcurrentHashMap<String, String> mapCur = new ConcurrentHashMap<>();
        // key不存在，则调用回调方法插入
        mapCur.computeIfAbsent("cc1", key -> {
            //mapCur.put("cc1", "v2");//死循环（HashMap则不会）
            return "v1";
        });


        mapCur.put("a", "v");

        mapCur.get("a");
    }
}
